function detail(data:Object, context):Object
{
	var content:String="";

	content+="<moonlight name='"+context.slot+"' template='"+context.slot+"-"+context.container+"' uri='"+context.uri+"'>";
	// content+="<portlet name='booksContainer' x='0' y='0' layout='area:400:640' >";

	var dataCollection=data.objects;
	
	for (var i=0; i<dataCollection.length; i++)
	{
		content+=getMemberSummaryItem(dataCollection[i], context);
	}
	
	content+="<portlet name='#gap' width='620' height='10' curve='0' colorstart='0xfffff' colorend='0xffffff' alphastart='0' alphaend='0'><handler ins='"+context.slot+"-"+context.container+"' type='onMLInit' value='"+context.slot+"' src='"+context.initMethod+"'/></portlet>";
	content+="</moonlight>";

	var voData:Object=new Object();
	voData.content=content;
	voData.type="Template";

	// Packages.log("content: "+content, "debug");

	return voData;
}

function getMemberSummaryItem(item:Object, context:Object):String
{
	if (item.memberId==null || item.nickName==null) return "";

	var cont:String="";
	cont+="<portlet name='#hgap_"+item.memberId+"' width='10' height='110' curve='0' colorstart='0xffffff' colorend='0xffffff' alphastart='0' alphaend='0'/>";
	cont+="<portlet name='memberItem_"+item.memberId+"' height='100' width='300' >"
	cont+="<textfield name='header' bgcolor='0xffffff' width='240' html='true' x='28' y='-10' selectable='no' >"+item.nickName+"</textfield>";
	if (item.image!=null)
	{
		// cont+="<media name='bookCover_"+item.bookId+"' x='13' y='10' type='image' width='64' height='80' src='"+item.image+"'/>";
		cont+="<portlet name='picCover_"+item.memberId+"' x='10' y='10' height='80' width='80' />"
	}
	else
	{
		//cont+="<portlet name='bookCover_"+item.bookId+"' x='10' y='7' linew='-1' curve='0' width='64' height='80'>";
		cont+="<textfield name='imageLabel_"+item.memberId+"' x='30' y='42' selectable='no' html='html' width='40'>PicLabel</textfield>";
	}
	cont+="<textfield name='description' x='95' y='5' selectable='no' html='true' width='200' height='65'>"+item.aboutMe+"</textfield>";
	cont+="<textfield name='lastLoginLabel' x='95' y='70' width='80' selectable='no' html='true'>LastLoginLabel</textfield>";
	cont+="<textfield name='lastLoginValue' x='160' y='70' width='135' selectable='no' html='true'>"+(item.lastLoginTime?item.lastLoginTime:"")+"</textfield>";
	cont+=addHandler(item, context);
	cont+="</portlet>";

	return cont;
}

function addHandler(item:Object, context:Object):String
{
	var src:String="";

	src+="<handler ins='"+context.slot+"-memberItem_"+item.memberId+"' type='onRollOver' src='lib:notes.system.events.StateFulButtonEvent.invokeRollOverEvent'/>";
	src+="<handler ins='"+context.slot+"-memberItem_"+item.memberId+"' type='onRollOut' src='lib:notes.system.events.StateFulButtonEvent.invokeRollOutEvent'/>";
	src+="<handler ins='"+context.slot+"-memberItem_"+item.memberId+"' type='onPress' src='lib:notes.system.events.StateFulButtonEvent.invokePressEvent'/>";
	src+="<handler ins='"+context.slot+"-memberItem_"+item.memberId+"' type='onRelease' src='lib:notes.system.events.StateFulButtonEvent.invokeReleaseEvent'/>";
	src+="<handler ins='"+context.slot+"-memberItem_"+item.memberId+"' type='onReleaseOutside' src='lib:notes.system.events.StateFulButtonEvent.invokeRollOutEvent'/>";

	return src;
}

function addPageSection(context):String
{
	var cont:String="";
	cont+="<textfield name='memberListPreLabel' x='20' y='405' width='50' selectable='no' html='true'>MemberListPreLabel</textfield>";
	cont+="<hotspot name='memberListPreSpot' x='20' y='405' alpha='0' width='50' height='20'/>";
	cont+="<textfield name='memberListCurrentPage' type='input' x='65' y='405' width='25'>1</textfield>";
	cont+="<textfield name='memberListSlash' x='95' y='405' width='10' selectable='no' html='true'>/</textfield>";
	cont+="<textfield name='memberListTotalPage' x='105' y='405' width='25' selectable='no' html='true'>1</textfield>";
	cont+="<textfield name='memberListNextLabel' x='130' y='405' width='50' selectable='no' html='true'>MemberListNextLabel</textfield>";
	cont+="<hotspot name='memberListNextSpot' x='130' y='405' alpha='0' width='50' height='20'/>";
	cont+="<handler ins='"+context.slot+"-"+context.container+"' type='onKeyUp' value='13' src='"+context.enterEvent+"'><arg name='"+context.slot+"-"+context.container+"' as='pageNum'/></handler>";
	
	return cont;
}

/*
{"count":1,"members":[{"locationCity":"Shanghai","birthday":"0000-00-00","createTime":"2008-09-23 22:18:34.0","locationCountry":"China","accessTime":"2008-12-29 11:02:15.0","updateTime":"2008-09-23 22:17:41.0","image":"http://www.image.com/1.jpg","aboutMe":"this is member1","homepage":"http://www.mysite1.com","nickName":"member1","email":"member1@readjoy.cn","gender":"M","memberId":1,"lastLoginTime":"2008-12-29 11:01:46.0"}]}
*/

function getUserImageItem(item:Object, context:Object):String
{
	if (item.memberId==null || item.nickName==null) return "";

	var cont:String="";
	cont+="<portlet name='container_"+item.memberId+"' width='62' height='70'>";
	cont+="<portlet name='#hgap_"+item.memberId+"_"+context.container+"' width='7' height='70' curve='0' colorstart='0xffffff' colorend='0xffffff' alphastart='20' alphaend='20'/>";
	cont+="<portlet name='memberItem_"+item.memberId+"' height='70' width='50' >";
	if (item.image!=null)
	{
		cont+="<portlet name='picCover_"+item.memberId+"' height='70' width='50' />"
	}
	else
	{
		cont+="<textfield name='imageLabel_"+item.memberId+"' x='10' y='22' selectable='no' html='html' width='40'>PicLabel</textfield>";
	}
	// else 
	cont+="<textfield name='memberName_"+item.memberId+"' html='true' width='55' y='50' x='0'><p align='center'>"+item.nickName+"</p></textfield>";
	
	cont+=addHandler(item, context);
	cont+="</portlet></portlet>";

	return cont;
}

function getUserBasicItem(item:Object, context:Object):String
{
	if (item.memberId==null || item.nickName==null) return "";

	var cont:String="";
	cont+="<portlet name='container_"+item.memberId+"' height='100' width='240'>";
	cont+="<portlet name='#hgap_"+item.memberId+"' width='6' height='100' curve='0' colorstart='0xffffff' colorend='0xffffff' alphastart='0' alphaend='0'/>";
	cont+="<portlet name='memberItem_"+item.memberId+"' height='80' width='240' >"
	if (item.image!=null)
	{
		// cont+="<media name='bookCover_"+item.bookId+"' x='13' y='10' type='image' width='64' height='80' src='"+item.image+"'/>";
		cont+="<portlet name='picCover_"+item.memberId+"' x='0' y='0' height='80' width='80' />"
	}
	else
	{
		//cont+="<portlet name='bookCover_"+item.bookId+"' x='10' y='7' linew='-1' curve='0' width='64' height='80'>";
		cont+="<textfield name='imageLabel_"+item.memberId+"' x='20' y='32' selectable='no' html='html' width='40'>PicLabel</textfield>";
	}
	cont+="<textfield name='name' width='150' html='true' x='85' y='0' selectable='no' >"+item.nickName+"</textfield>";
	cont+="<textfield name='description' x='85' y='20' selectable='no' html='true' width='150' height='45'>"+item.aboutMe+"</textfield>";
	cont+="<textfield name='lastLoginValue' x='85' y='65' width='150' selectable='no' html='true'>"+(item.lastLoginTime?item.lastLoginTime:"")+"</textfield>";
	cont+=addHandler(item, context);
	cont+="</portlet></portlet>";

	return cont;
}

function normal(data:Object, context:Object)
{
	var content:String="";

	content+="<moonlight name='"+context.slot+"' template='"+context.slot+"-"+context.container+"' uri='"+context.uri+"'>";

	var dataCollection=data.members;
	// /*	@tmp - data clone
	var data_clone=dataCollection[0];
	for (var i=0; i<15; i++)
	{
		var data_cpy=new Object();
		for (var a in data_clone)
		{
			if (a=="memberId")
			{
				data_cpy[a]=data_clone[a]+i;
			}
			else data_cpy[a]=data_clone[a];
		}
		dataCollection.push(data_cpy);
	}
	// */
	dataCollection.reverse();
	
	for (var i=0; i<dataCollection.length; i++)
	{
		content+=getUserImageItem(dataCollection[i], context);
	}
	
	content+="<portlet name='@handler_"+context.container+"' x='420' y='130'><textfield name='moreOperLabel_"+context.container+"' html='true' width='80'>MoreOperLabel</textfield><hotspot name='moreSpot_"+context.container+"' width='60' height='20' alpha='0' /><handler ins='"+context.slot+"-"+context.container+"' type='onMLInit' value='"+context.slot+"' src='"+context.initMethod+"'/></portlet>";
	content+="</moonlight>";

	var voData:Object=new Object();
	voData.content=content;
	voData.type="Template";

	// Packages.log("content: "+voData.content, "debug");

	return voData;
}

function expand(data:Object, context:Object)
{
	var content:String="";

	content+="<moonlight name='"+context.slot+"' template='"+context.slot+"-"+context.container+"' uri='"+context.uri+"'>";

	// var dataCollection=data.books?data.books:data.objects;
	var dataCollection=data.members;
	// /*	@tmp - data clone
	var data_clone=dataCollection[0];
	for (var i=0; i<7; i++)
	{
		var data_cpy=new Object();
		for (var a in data_clone)
		{
			if (a=="memberId")
			{
				data_cpy[a]=data_clone[a]+i;
			}
			else data_cpy[a]=data_clone[a];
		}
		dataCollection.push(data_cpy);
	}
	// */
	dataCollection.reverse();
	
	for (var i=0; i<dataCollection.length; i++)
	{
		content+=getUserBasicItem(dataCollection[i], context);
	}
	
	content+="<portlet name='@handler_"+context.container+"' x='280' y='-15'><handler ins='"+context.slot+"-"+context.container+"' type='onMLInit' value='"+context.slot+"' src='"+context.initMethod+"'/>";
	content+=addPageSection(context);
	content+="</portlet></moonlight>";

	var voData:Object=new Object();
	voData.content=content;
	voData.type="Template";

	// Packages.log("content: "+voData.content, "debug");

	return voData;
}